//
//  ZJHongBaoShuoMingVC.m
//  英伦府邸
//
//  Created by IOS_DEVELOPER on 2017/7/27.
//  Copyright © 2017年 英伦府邸. All rights reserved.
//

#import "ZJHongBaoShuoMingVC.h"

@interface ZJHongBaoShuoMingVC ()

@property (weak, nonatomic) IBOutlet UIButton *sureBtn;
@property (weak, nonatomic) IBOutlet UILabel *topTitle;
@property (weak, nonatomic) IBOutlet UIView *bgview;

@end

@implementation ZJHongBaoShuoMingVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.sureBtn setBackgroundColor:[Utils colorWithHexString:allConstHexColor]];
    self.topTitle.textColor = [Utils colorWithHexString:allConstHexColor];
    NSArray * titleArr = @[@"1、红包活动是针对提前报名客户所发起的现金红包奖励活动，在规定时间段内可以通过APP抢红包功能随机抢得现金红包。",@"2、您需要在规定的时间内在指定的红包发生地才能抢到红包。红包奖励时间以及地点请到活动中心活动中心内红包活动信息中查看，在规定时间段内只能抢一次或数次红包，抢到即有。",@"3、您在24小时之内最多能获取一定限额的红包奖励。我的红包上限请到个人账户中查看。",@"4、抢红包所获金额在您的个人账户内，请在个人账户内进行提现等操作。",@"5、此红包活动最终解释权归海城集团所有。"];
    
    NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    [paragraphStyle setLineSpacing:5];

    
    NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:titleArr[0] attributes:@{NSForegroundColorAttributeName : RGB(48, 48, 48), NSParagraphStyleAttributeName: paragraphStyle}];
    [string addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:13.0f] range:NSMakeRange(9, 10)];
    [string addAttribute:NSForegroundColorAttributeName value:[Utils colorWithHexString:allConstHexColor] range:NSMakeRange(9, 10)];

    NSMutableAttributedString *string1 = [[NSMutableAttributedString alloc] initWithString:titleArr[1] attributes:@{NSForegroundColorAttributeName : RGB(48, 48, 48), NSParagraphStyleAttributeName: paragraphStyle}];
    [string1 addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:13.0f] range:NSMakeRange(28, 54)];
    [string1 addAttribute:NSForegroundColorAttributeName value:[Utils colorWithHexString:allConstHexColor] range:NSMakeRange(28, 54)];
    
    NSMutableAttributedString *string2 = [[NSMutableAttributedString alloc] initWithString:titleArr[2] attributes:@{NSForegroundColorAttributeName : RGB(48, 48, 48), NSParagraphStyleAttributeName: paragraphStyle}];

    NSMutableAttributedString *string3 = [[NSMutableAttributedString alloc] initWithString:titleArr[3] attributes:@{NSForegroundColorAttributeName : RGB(48, 48, 48), NSParagraphStyleAttributeName: paragraphStyle}];

    NSMutableAttributedString *string4 = [[NSMutableAttributedString alloc] initWithString:titleArr[4] attributes:@{NSForegroundColorAttributeName : RGB(48, 48, 48), NSParagraphStyleAttributeName: paragraphStyle}];

    UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(16, self.topTitle.y + self.topTitle.height + 34, SCREEN_WIDTH - 32, [self getSpaceLabelHeightwithSpeace:8 withFont:[UIFont systemFontOfSize:13.0f] withWidth:SCREEN_WIDTH - 32 mtStr:string.string])];
    label.numberOfLines = 0;
    label.font = [UIFont systemFontOfSize:13.0f];

    UILabel * label1 = [[UILabel alloc]initWithFrame:CGRectMake(16, label.y + label.height + 24, SCREEN_WIDTH - 32, [self getSpaceLabelHeightwithSpeace:8 withFont:[UIFont systemFontOfSize:13.0f] withWidth:SCREEN_WIDTH - 32 mtStr:string1.string])];
    label1.numberOfLines = 0;
    label1.font = [UIFont systemFontOfSize:13.0f];
    
    UILabel * label2 = [[UILabel alloc]initWithFrame:CGRectMake(16, label1.y + label1.height + 24, SCREEN_WIDTH - 32, [self getSpaceLabelHeightwithSpeace:8 withFont:[UIFont systemFontOfSize:13.0f] withWidth:SCREEN_WIDTH - 32 mtStr:string2.string])];
    label2.numberOfLines = 0;
    label2.font = [UIFont systemFontOfSize:13.0f];
    
    UILabel * label3 = [[UILabel alloc]initWithFrame:CGRectMake(16, label2.y + label2.height + 24, SCREEN_WIDTH - 32, [self getSpaceLabelHeightwithSpeace:8 withFont:[UIFont systemFontOfSize:13.0f] withWidth:SCREEN_WIDTH - 32 mtStr:string3.string])];
    label3.numberOfLines = 0;
    label3.font = [UIFont systemFontOfSize:13.0f];
    
    UILabel * label4 = [[UILabel alloc]initWithFrame:CGRectMake(16, label3.y + label3.height + 24, SCREEN_WIDTH - 32, [self getSpaceLabelHeightwithSpeace:8 withFont:[UIFont systemFontOfSize:13.0f] withWidth:SCREEN_WIDTH - 32 mtStr:string4.string])];
    label4.numberOfLines = 0;
    label4.font = [UIFont systemFontOfSize:13.0f];
    
    label.attributedText = string;
    label1.attributedText = string1;
    label2.attributedText = string2;
    label3.attributedText = string3;
    label4.attributedText = string4;

     [self.bgview addSubview:label];
     [self.bgview addSubview:label1];
     [self.bgview addSubview:label2];
     [self.bgview addSubview:label3];
     [self.bgview addSubview:label4];
    
}

- (IBAction)sureBtn:(UIButton *)sender {
    
    [self dismissSemiModalView];
}


-(CGFloat)getSpaceLabelHeightwithSpeace:(CGFloat)lineSpeace withFont:(UIFont*)font withWidth:(CGFloat)width mtStr:(NSString *)mtStr {
    NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
    //    paraStyle.lineBreakMode = NSLineBreakByCharWrapping;
    /** 行高 */
    paraStyle.lineSpacing = lineSpeace;
    // NSKernAttributeName字体间距
    NSDictionary *dic = @{NSFontAttributeName:font, NSParagraphStyleAttributeName:paraStyle, NSKernAttributeName:@1.5f
                          };
    CGSize size = [mtStr boundingRectWithSize:CGSizeMake(width,MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil].size;
    return size.height;
}


@end
